<?php
namespace app\admin\controller;
use app\admin\controller\Base;
use app\admin\model\StaffsModel as M;
class Staff extends Base{
    public function index(){
        $this->isLogin();
        $m = new M();
        $res = $m->users();
        $this->assign('res',$res);
        return $this->fetch();
    }
    public function edit(){
        $this->isLogin();
        $m = new M();
        $res = $m->edit();
        $this->assign('res',$res);
        return $this->fetch('edit');
    }
    public function upload(){
        $this->isLogin();
        $file = request()->file('file');
        // 移动到框架应用根目录/public/uploads/ 目录下
        if($file){
            $info = $file->move(ROOT_PATH . 'public' . DS . 'upload/staffs');
            if($info){
                // 成功上传后 获取上传信息
                // 输出 20160820/42a79759f284b767dfcb2a0197904287.jpg
                return $getSaveName = $info->getSaveName();
            }else{
                // 上传失败获取错误信息
                echo $file->getError();
            }
        }

    }
    public function toEdit(){
        $this->isLogin();
        $m = new M();
        return $m->editMsg();
    }

}